<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" value="" id="val1">
    <button>+</button>
    <input type="text" value="" id="val2">
    <button id="btn">=</button>
    <input type="text" value="" id="val3">
    <script>
        /* val1 = > 就是id等于val1的那个标签
           获取val1 上面的 value 值 => 那就使用val1.value
        */
        // console.log(val1.value);

        /* 给标签赋值 */
        // val3.value = "文渊"//赋值
        // value.value
        //给btn按钮绑定一个点击事件
        btn.onclick = function () {
            var v1 = +val1.value;    //获取id等于val1
            var v2 = +val2.value;    //获取id等于val2
            var result = v1 + v2;     //将那两个文本框的值相加
            val3.value = result;     //将加出来的结果赋值给id为val3的那个文本框
        }
    </script>
</body>

</html>